import request from "@/utils/request";
import {BaseResponse} from "@/api/types/baseResponse";
import {ShopUserResponse} from "@/api/types/shopUser";

// 根据门店ID查询门店人员
export async function getShopUsersByShopId(shopId: number) {
    return await request<
        BaseResponse<{ user_list: ShopUserResponse[] }>,
        BaseResponse<{ user_list: ShopUserResponse[] }>
    >({
        url: "/kaoqin/shopuser",
        method: "GET",
        params: {shopid: shopId}
    })
}

// 将人员增加到门店
export async function addShopUserToShop(shopId: number, shopUserIds: string[]) {
    return await request<BaseResponse<unknown>, BaseResponse<unknown>>({
        url: "/kaoqin/shopuser",
        method: "POST",
        data: {shopid: shopId, userid: shopUserIds}
    })
}

// 将人员从门店删除
export async function deleteShopUserFromShop(shopId: number, shopUserId: string) {
    return await request<BaseResponse<unknown>, BaseResponse<unknown>>({
        url: "/kaoqin/shopuser",
        method: "DELETE",
        data: {shopid: shopId, userid: shopUserId}
    })
}

// 修改某个门店人员是不是店长的状态
export async function changeManagerOfShop(shopId: number, shopUserId: string) {
    return await request<BaseResponse<undefined>, BaseResponse<undefined>>({
        url: "/kaoqin/shopuser",
        method: "PUT",
        data: {shopid: shopId, userid: shopUserId}
    })
}
